import StorageUtil from "@/utils/StorageUtil";
import UserVO from "@/model/user/UserVO";

export default class UserStorageUtil {
    // 开发生产区分user，避免混淆，不区分的话会冲突
    private static readonly user_key: string = 'user_key'
    private static readonly dev_user_key: string = 'dev_user_key'

    static set(user: UserVO) {
        if (process.env.NODE_ENV === 'development') {
            StorageUtil.setObj(this.dev_user_key, user)
        } else {
            StorageUtil.setObj(this.user_key, user)
        }
    }

    static get() {
        // 开发环境方便测试
        if (process.env.NODE_ENV === 'development') {
            // return StorageUtil.getObj(this.dev_user_key)
            return {
                "provider": 'weixin',
                "platform": "mp",
                "clientid": "",
                "openId": "",
                "unionId": "",
                "accessToken": "",
                "code": "021epl000jzMkL136z200JwZff1epl0V",
                "nickName": "不会魔法",
                "avatarUrl": "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83erFFcuGCzsjBx5SqhiaYX1sdV6vErEBb8xZC9DAObtETtMtTECM9RCHtqmSgVlqCFMoCvQOzGvy7pw/132",
                "gender": '男',
                "birthday": "",
                "city": "Chaoyang",
                "phoneNum": "",
                "authCode": "",
                "encryptedData": "/0ldARck3mPlV/lzoozWkpBcKwTRAKOos/dwyhl6DDS38hsMBWyMaL/W6RGSKE4HoTkDLvG3lr8j4apk2Y4Xyg7sNF9WrJsnwMeVEvXGCVdPJ5+fH2ln8DrBbWdJZlMwspGzgFBFXdVvWK2KD5lFD/SnHmjgOo9X/MFoPY93cbJHFo11Xsy7Pvrqz5RBua6mNyhdtdpm9jTxYddpnGVrI94eWI94CJBSZ3bzZcFQy/v8SD6m+hPU5FJruvxkkmmB+zyKAFbcZvOqHUs16IxYwMJLyvVwjZtQ5QyzX0pGsh7naqiazYpnX9m1gCEZQFQ7Vm8YV3G8cJHDqPFNuNoLESinWulLA4vy6OLYZJvL8atVfBiR468HwydEJHc1Ks9B4FQRQ6F9g82y43DCCd8tB05xMdzAbBRjN623GS6S8S20Kk1hFZ6CUNCs5y2ldiJzmdQswYBwzIutcM9Axby2Y060lPzWSC/JesXctoytEbA=",
                "iv": "FchqqUklEZ+PdIOL3mCTYA==",
                "sessionEnable": false,
                "inviteCode": "",
                "language": "zh_CN",
                "province": "Beijing",
                "country": "China"
            }
            // return 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxNl81YWVkZTMwZDA3NDc0NTgwOThjZTAzYTVjMWY3MTc4OCJ9.XlQXd_4afra45_b_P6wsIgMxdi779xhfwM03oci8vOI'
        } else {
            return StorageUtil.getObj(this.user_key)
        }
    }

    static remove() {
        if (process.env.NODE_ENV === 'development') {
            StorageUtil.remove(this.dev_user_key)
        } else {
            StorageUtil.remove(this.user_key)
        }
    }
}
